﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace utd_hrrs
{
    public partial class SupervisorPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {

        }

        protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {            
            if (TextBox9.Text == "" || TextBox12.Text == "" || TextBox11.Text == "")
            {
                Label2.Visible = true;
            }          
            else
            {
 
                String desc = TextBox9.Text;
                String sch = TextBox12.Text;
                String inv = TextBox11.Text;
                SqlConnection conn = null;              
                conn = new SqlConnection("Data Source=rockstar.hopto.org,11433;Initial Catalog=UTD_HRRS;User ID=utd_hrrs;Password=bhowmik6360");                
                conn.Open();
                String sqlCommand = "insert into MAINTENANCE (DESCRIPTION, SCHEDULE_DAY, INV_ID) values ( '" + desc + "', '" + sch + "', " + inv + ");";
                SqlCommand command = new SqlCommand(sqlCommand, conn);
                String returnvalue = (String)command.ExecuteScalar();
                conn.Close();
                Response.Redirect(Request.RawUrl);
            }
            

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (TextBox18.Text == "" || TextBox19.Text == "" || TextBox20.Text == "")
            {
                Label4.Visible = true;
            }
            else
            {
                String prob = TextBox19.Text;
                String sch = TextBox18.Text;
                String inv = TextBox20.Text;
                // 1. Create your SQL Connection 
                SqlConnection conn = null;
                // 2. Create and open a connection object 
                conn = new SqlConnection("Data Source=rockstar.hopto.org,11433;Initial Catalog=UTD_HRRS;User ID=utd_hrrs;Password=bhowmik6360");
                // 3. Open the Connection 
                conn.Open();
                String sqlCommand = "insert into REPAIR (SCHEDULE_DAY, PROBLEM, INV_ID) values ( '" + sch + "', '" + prob + "', " + inv + ");";
                SqlCommand command = new SqlCommand(sqlCommand, conn);
                String returnvalue = (String)command.ExecuteScalar();
                conn.Close();
                Response.Redirect(Request.RawUrl);
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("Supervisor.aspx");
        }

        
        


    

        /*protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        
        protected void Remove1_Click(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            GridViewRow row = (GridViewRow)b.NamingContainer;

            // get the value of the textbox
            //TextBox txt1 = row.Cells[4].FindControl("TextBox1") as TextBox;
            //string phoneNumber = txt1.Text;

            // get the Primary Key Value
            String desc = GridView1.DataKeys[row.RowIndex].Value as String;
            //DateTime date = GridView1.DataKeys[row.RowIndex].Value as DateTime;
            // ... Do something with these values like update a row in a database
            //

            
        }*/
    }
}
